package cn.brilliantfuture.commentry.entity;

// Generated 2011-11-3 13:34:34 by Hibernate Tools 3.3.0.GA

import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

/**
 * Area generated by hbm2java
 */
@Entity
@Table(name = "area", catalog = "cabinet")
public class Area implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	private Integer areaId;
	private String name;
	private String pinyin;
	// 1为省；2为市；3为区县
	private Integer level;
	private Area area;
	private boolean deleted;
	private Set<Villiage> villiages = new HashSet<Villiage>(0);

	public Area() {
	}

	public Area(boolean deleted) {
		this.deleted = deleted;
	}

	public Area(String name, boolean deleted, Area area) {
		this.name = name;
		this.deleted = deleted;
		this.area = area;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "area_id", unique = true, nullable = false)
	public Integer getAreaId() {
		return this.areaId;
	}

	public void setAreaId(Integer areaId) {
		this.areaId = areaId;
	}

	@Column(name = "name", length = 45)
	@Length(max = 45)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "deleted", nullable = false)
	public boolean isDeleted() {
		return this.deleted;
	}

	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "father_area_id")
	public Area getArea() {
		return this.area;
	}

	public void setArea(Area area) {
		this.area = area;
	}
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "area")
	public Set<Villiage> getVilliages() {
		return villiages;
	}

	public void setVilliages(Set<Villiage> villiages) {
		this.villiages = villiages;
	}

	@Column(name = "pinyin", length = 50)
	@Length(max = 50)
	public String getPinyin() {
		return pinyin;
	}

	public void setPinyin(String pinyin) {
		this.pinyin = pinyin;
	}

	@Column(name = "level", nullable = false)
	@NotNull
	public Integer getLevel() {
		return level;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}
}
